import React, { Component } from "react";
import { createPortal } from "react-dom";
// createPortal方法需要传入两个参数，第一个是组件，第二个是放的dom容器

class Child extends Component {
  render() {
    return createPortal(<div>child组件</div>, document.querySelector("body"));
  }
}

class App extends Component {
  render() {
    return (
      <div className="container">
        <h3>portal</h3>
        <Child />
      </div>
    );
  }
}

export default App;
